/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package biofilter.factories;

import biofilter.data.Sequence.BioSequence;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author qvh
 */
public class BioSequenceFactoryTest {

    public BioSequenceFactoryTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of getBioSequence method, of class BioSequenceFactory.
     */
    @Test
    public void testGetBioSequence() {
        System.out.println("getBioSequence");
        String s = "atgcatnnnatatnggccc";
        BioSequenceFactory instance = new BioSequenceFactory();
        BioSequence result = instance.getBioSequence(s);
        assertEquals("class biofilter.data.Sequence.NASequence", result.getClass().toString());
        String p = "MDFIVAIFALFVISSFTITSTNAVEASTLLDIGNLSRSSFPRGFI";
        result = instance.getBioSequence(p);
        assertEquals("class biofilter.data.Sequence.Protein", result.getClass().toString());

    }

    /**
     * Following is a series of tests for functionality of the BioSequence base class... it is abstract and thus not
     * instantiatable without the factory, so this is as good of a place as any to place such functionality.
     */

    /**
     * Test of BioSequence's format number
     * @param i
     */
    @Test
    public void testFormatNumber(){
        System.out.println("formatNumber");
        String s = "atgcatnnnatatnggccc";
        BioSequenceFactory instance = new BioSequenceFactory();
        BioSequence bios = instance.getBioSequence(s);
        assertEquals("       60", bios.formatNumber(60));
        assertEquals("      120", bios.formatNumber(120));
        assertEquals("     1859", bios.formatNumber(1859));
    }

    private String s = "aaacaaaccaaatatggattttattgtagccatatttgctctgtttgttattagctcattcacaattacttccacaaatgcagttgaagcttctactcttcttgacataggtaacctgagtcggagcagttttcctcgtggcttcatctttggtgctggatcttcagcataccaatttgaaggtgcagtaaacgaaggcggtagaggaccaagtatttgggataccttcacccataaatatccagaaaaaataagggatggaagcaatgcagacatcacggttgaccaatatcaccgctacaaggaagatgttgggattatgaaggatcaaaatatggattcgtatagattctcaatctcttggccaagaatactcccaaagggaaagttgagcggaggcataaatcacgaaggaatcaaatattacaacaaccttatcaacgaactattggctaacggtatacaaccatttgtaactctttttcattgggatcttccccaagtcttagaagatgagtatggtggtttcttaaactccggtgtaataaatgattttcgagactatacggatctttgcttcaaggaatttggagatagagtgaggtattggagtactctaaatgagccatgggtgtttagcaattctggatatgcactaggaacaaatgcaccaggtcgatgttcggcctccaacgtggccaagcctggtgattctggaacaggaccttatatagttacacacaatcaaattcttgctcatgcagaagctgtacatgtgtataagactaaataccaggcatatcaaaagggaaagataggcataacgttggtatctaactggttaatgccacttgatgataatagcataccagatataaaggctgccgagagatcacttgacttccaatttggattgtttatggaacaattaacaacaggagattattctaagagcatgcggcgtatagttaaaaaccgattacctaagttctcaaaattcgaatcaagcctagtgaatggttcatttgattttattggtataaactattactcttctagttatattagcaatgccccttcacatggcaatgccaaacccagttactcaacaaatcctatgaccaatatttcatttgaaaaacatgggatacccttaggtccaagggctgcttcaatttggatatatgtttatccatatatgtttatccaagaggacttcgagatcttttgttacatattaaaaataaatataacaatcctgcaattttcaatcactgaaaatggtatgaatgaattcaacgatgcaacacttccagtagaagaagctcttttgaatacttacagaattgattactattaccgtcacttatactacattcgttctgcaatcagggctggctcaaatgtgaagggtttttacgcatggtcatttttggactgtaatgaatggtttgcaggctttactgttcgttttggattaaactttgtagattagaaagatggattaaaaaggtaccctaagctttctgcccaatggtacaagaactttctcaaaagaaactagctagtattattaaaagaactttgtagtagattacagtacatcgtttgaagttgagttggtgcacctaattaaataaaagaggttactcttaacatatttttaggccattcgttgtgaagttgttaggctgttatttctattatactatgttgtagtaataagtgcattgttgtaccagaagctatgatcataactataggttgatccttcatgtatcagtttgatgttgagaatactttgaattaaaagtctttttttatttttttaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    private String emblStr = "     aaacaaacca aatatggatt ttattgtagc catatttgct ctgtttgtta ttagctcatt        60\n     cacaattact tccacaaatg cagttgaagc ttctactctt cttgacatag gtaacctgag       120\n     tcggagcagt tttcctcgtg gcttcatctt tggtgctgga tcttcagcat accaatttga       180\n     aggtgcagta aacgaaggcg gtagaggacc aagtatttgg gataccttca cccataaata       240\n     tccagaaaaa ataagggatg gaagcaatgc agacatcacg gttgaccaat atcaccgcta       300\n     caaggaagat gttgggatta tgaaggatca aaatatggat tcgtatagat tctcaatctc       360\n     ttggccaaga atactcccaa agggaaagtt gagcggaggc ataaatcacg aaggaatcaa       420\n     atattacaac aaccttatca acgaactatt ggctaacggt atacaaccat ttgtaactct       480\n     ttttcattgg gatcttcccc aagtcttaga agatgagtat ggtggtttct taaactccgg       540\n     tgtaataaat gattttcgag actatacgga tctttgcttc aaggaatttg gagatagagt       600\n     gaggtattgg agtactctaa atgagccatg ggtgtttagc aattctggat atgcactagg       660\n     aacaaatgca ccaggtcgat gttcggcctc caacgtggcc aagcctggtg attctggaac       720\n     aggaccttat atagttacac acaatcaaat tcttgctcat gcagaagctg tacatgtgta       780\n     taagactaaa taccaggcat atcaaaaggg aaagataggc ataacgttgg tatctaactg       840\n     gttaatgcca cttgatgata atagcatacc agatataaag gctgccgaga gatcacttga       900\n     cttccaattt ggattgttta tggaacaatt aacaacagga gattattcta agagcatgcg       960\n     gcgtatagtt aaaaaccgat tacctaagtt ctcaaaattc gaatcaagcc tagtgaatgg      1020\n     ttcatttgat tttattggta taaactatta ctcttctagt tatattagca atgccccttc      1080\n     acatggcaat gccaaaccca gttactcaac aaatcctatg accaatattt catttgaaaa      1140\n     acatgggata cccttaggtc caagggctgc ttcaatttgg atatatgttt atccatatat      1200\n     gtttatccaa gaggacttcg agatcttttg ttacatatta aaaataaata taacaatcct      1260\n     gcaattttca atcactgaaa atggtatgaa tgaattcaac gatgcaacac ttccagtaga      1320\n     agaagctctt ttgaatactt acagaattga ttactattac cgtcacttat actacattcg      1380\n     ttctgcaatc agggctggct caaatgtgaa gggtttttac gcatggtcat ttttggactg      1440\n     taatgaatgg tttgcaggct ttactgttcg ttttggatta aactttgtag attagaaaga      1500\n     tggattaaaa aggtacccta agctttctgc ccaatggtac aagaactttc tcaaaagaaa      1560\n     ctagctagta ttattaaaag aactttgtag tagattacag tacatcgttt gaagttgagt      1620\n     tggtgcacct aattaaataa aagaggttac tcttaacata tttttaggcc attcgttgtg      1680\n     aagttgttag gctgttattt ctattatact atgttgtagt aataagtgca ttgttgtacc      1740\n     agaagctatg atcataacta taggttgatc cttcatgtat cagtttgatg ttgagaatac      1800\n     tttgaattaa aagtcttttt ttattttttt aaaaaaaaaa aaaaaaaaaa aaaaaaaaa       1859\n";
    @Test
    public void testGetEMBL(){
        System.out.println("getEMBL");
        BioSequenceFactory instance = new BioSequenceFactory();
        BioSequence bios = instance.getBioSequence(s);
        //System.err.print(bios.getEMBL());
        assertEquals(emblStr, bios.getEMBL());
    }


    @Test
    public void testSetEMBL(){
        System.out.println("setEMBL");
        BioSequenceFactory instance = new BioSequenceFactory();
        BioSequence bios = instance.getBioSequence(s);
        bios.setEMBL(emblStr);
        //System.err.print(bios.getEMBL());
        assertEquals(s, bios.get());
    }
}